<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="format-detection" content="telephone=no">
<meta http-equiv="Cache-Control" content="no-siteapp">
<link rel="stylesheet" href="../../../static/layui/css/layui.css" media="all" />
<link rel="stylesheet" href="../../../static/css/public.css" media="all" />
<link rel="stylesheet" href="../../../static/plugin/zTree/css/zTreeStyle/zTreeStyle.css" type="text/css">
</head>
<body class="childrenBody">
	<form class="layui-form">
		<blockquote class="layui-elem-quote quoteBox">
			<form class="layui-form">
				<div class="layui-inline">
					<label class="layui-form-label">日期</label>
					<div class="layui-input-block">
						<input type="text" class="layui-input searchVal" name="date" id="date"> <input type="hidden" class="layui-input searchVal" name="year" id="year"> <input type="hidden" class="layui-input searchVal" name="month" id="month">
					</div>
				</div>
			</form>
		</blockquote>
		<blockquote class="layui-elem-quote quoteBox">
			<div class="layui-inline">
				<a class="layui-btn search-btn" data-type="reload">搜索</a>
			</div>
		</blockquote>
		<table id="list" lay-filter="list"></table>
		<div class="list-page" id="page"></div>
	</form>
	<script type="text/javascript" src="../../../static/js/jquery-2.1.1.min.js"></script>
	<script type="text/javascript" src="../../../static/layui/layui.js"></script>
	<script type="text/javascript" src="../../../static/custom/js/common.js"></script>
	<script type="text/javascript" src="../../../static/plugin/zTree/js/jquery.ztree.core.js"></script>
	<script type="text/javascript">
		layui.use([ 'form', 'layer', 'table', 'laytpl', 'laydate' ], function() {
			var listApi = '../../../attendance/atdtable/listSelf';
			var confirmAtdTableApi = '../../../attendance/atdtable/confirmAtdTable';
			var cols = [ [ {
				field : 'ername',
				title : '员工',
				align : "center"
			}, {
				field : 'dname',
				title : '部门',
				align : "center"
			}, {
				field : 'pname',
				title : '岗位',
				align : "center"
			}, {
				field : 'shouldAttd',
				title : '应出勤天数',
				align : 'center'
			}, {
				field : 'actualAttd',
				title : '实出勤天数',
				align : 'center'
			}, {
				field : 'paidAnnualLeave',
				title : '带薪年假天数',
				align : 'center'
			},{
				field : 'paidLeave',
				title : '带薪调休天数',
				align : 'center'
			}, {
				field : 'generalLeave',
				title : '普通请假天数',
				align : 'center'
			}, {
				field : 'lateAndEarlyLeave',
				title : '迟到和早退分钟数',
				width : 150,
				align : 'center'
			}, {
				field : 'goout',
				title : '外出天数',
				align : 'center'
			}, {
				field : 'overtime',
				title : '加班小时数',
				align : 'center'
			}, {
				field : 'absenteeism',
				title : '旷工天数',
				align : 'center'
			}, {
				title : '操作',
				align : 'center',
				templet : function(d) {
					var str = '';
					if (hasPermission('000500400000') && d.isConfirmed == 2) {
						str += '<a class="layui-btn layui-btn-xs" lay-event="confirmAtd">确认考勤</a>';
					} else if(d.isConfirmed == 1){
						str += "已确认";
					}
					return str;
				}
			} ] ];
			var pram = merger(getsearchVal());
			var form = layui.form, layer = parent.layer === undefined ? layui.layer : top.layer;
			var $ = layui.jquery;
			var laytpl = layui.laytpl;
			var table = layui.table;
			var laydate = layui.laydate;
			tableIns = table.render({
				elem : '#list',
				cellMinWidth : constant.table.cellMinWidth,
				page : false,
				height : constant.table.height,
				cols : cols,
				done : function(res, page, count) {
					checkAll(form);
				}
			});

			//获取上一个月
			function getBeforeMonth() {
				var d = new Date();
				var currentYear = new Date().getFullYear();
				var currentMonth = new Date().getMonth() + 1;
				var beforeMonth = currentMonth - 1;
				if (beforeMonth == 0) {
					currentYear -= 1;
					beforeMonth = 12;
				}
				if (beforeMonth < 10) {
					beforeMonth = "0" + beforeMonth;
				}
				return {
					year : currentYear,
					month : beforeMonth
				};
			}
			//执行一个laydate实例
			laydate.render({
				elem : '#date',
				type : 'month',
				value : getBeforeMonth().year + "-" + getBeforeMonth().month,
				done : function(value, date, endDate) {
					$("#year").val(date.year);
					$("#month").val(date.month < 10 ? "0" + date.month : date.month);
				}
			});//列表操作
			table.on('tool(list)', function(obj) {
				var layEvent = obj.event;
				if (layEvent === 'confirmAtd') {
					//确认考勤
					confirmLayer('提示信息', '确定考勤报表？确定后不可修改！', function(confirm, index) {
						loadAjax(confirmAtdTableApi, "put", null, function(response) {
							baseCallBack(response, function(response) {
								layer.msg(response.msg);
								listLoad(pram);
								confirm.close(index);
							});
						});
					})
				}
			});
			//用户列表
			listLoad(pram);
			function listLoad(data) {
				loadAjax(listApi, "get", data, function(response) {
					baseCallBack(response, function(response) {
						table.reload("list", {
							data : [ response.data ]
						})
					});
				});
			}

			//搜索【此功能需要后台配合，所以暂时没有动态效果演示】
			$(".search-btn").on("click", function() {
				pram = merger(pram, getsearchVal());
				listLoad(pram);
			});

		})
	</script>
</body>
</html>